// import http from "./http";
import http from "@/utils/http";
import {BASE_URL} from "../../../common/const";

import * as fn from "./utils";



/**
 * 股票搜索
 * @param {Object} params
 * @param {Number} params.path
 * @param {Number} params.pageSize - 请求条数
 * @param {String} params.name - 股票名称
 * @return {Promise} Array
 */
export async function getStockList(params)
{
  const url = "http://app.yueniucj.com/app/clickSearchContent.htm";
  const send = {
    searchType: 1,
    limit: 10,
    ...params
  };
  const res = await fetch(`${url}?${fn.objToParamStr(send)}`);
  const {
    data
  } = await res.json();
  return data;
}

/** 根据产品id查询直播室信息-H5*/
export async function getRoom(option)
{
  const url = `${BASE_URL}/client/room/info.htm`;
  const params = {
    ...option
  };
  const res = await http.get(url, { ...option });
  return res;
}


/** app获取公告信息-H5*/
export async function getInfo(option)
{
  const url = `${BASE_URL}/client/room/notice/info.htm`;
  const params = {
    roomId: 2,
    ...option
  };
  const res = await http.get(url, { ...params });
  return res;
}


/** 直播内容列表*/
export async function getLiveList(option)
{
  const url = `${BASE_URL}/client/room/content/info.htm`;
  const params = {
    roomId: 2,
    limit: 20,
    ...option
  };
  const res = await http.get(url, { ...params });
  return res.data;
}


/** 私信列表*/
export async function getMsgList(option)
{
  const url = `${BASE_URL}/client/room/msg/list.htm`;
  const params = {
    roomId: 2,
    limit: 20,
    userType: 0,
    ...option
  };
  const res = await http.get(url, { ...params });
  return res.data;
}



/** 发布私信内容*/
export async function postMsg(option)
{
  const url = `${BASE_URL}/client/room/msg/pub.htm`;
  const params = {
    roomId: 2,
    ...option
  };
  const res = await http.post(url, {...params});
  return res;
}

/** 发布互动内容*/
export async function postLive(option)
{
  const url = `${BASE_URL}/client/room/msg/interaction.htm`;
  const params = {
    roomId: 2,
    ...option
  };
  const res = await http.post(url, {...params});
  return res;
}



/**直播相关推送*/
export async function pushBroadcasting(option)
{
  const url = `${BASE_URL}/client/pushBroadcasting.htm`;
  const params = {
    ...option
  };
  const res = await http.post(url, params);
  return res;
}


/** 公告*/
export async function getNotice(option)
{
  const url = `${BASE_URL}/client/room/announcement/list.htm`;
  const params = {
    type: 1,
    limit: 20,
    ...option
  };
  const res = await http.get(url, { params });
  return res;
}



/** 精选列表*/
export async function getFineList(option)
{
  const url = `${BASE_URL}/client/room/fine/list.htm`;
  const params = {
    roomId: 2,
    limit: 20,
    ...option
  };
  const res = await http.get(url, { params });
  return res.data;
}




